package com.doudou.collection.controller;

import com.doudou.collection.mapper.BlogCategoriesMapper;
import com.doudou.collection.pojo.dto.BlogCategoriesDTO;
import com.doudou.collection.response.ResultVO;
import com.doudou.collection.service.BlogCategoriesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**@ClasName BlogCategoriesController
 * @Description 文章分类模块
 * @Auther 马凯良
 * @Date 2023/6/12 19:42
 * @Version 1.0
*/
@Api(tags="04.文章分类模块")
@Slf4j
@RestController
@RequestMapping("/v1/blogcategories")
public class BlogCategoriesController {
    @Autowired
    BlogCategoriesMapper categoriesMapper;

    @Autowired
    BlogCategoriesService blogCategoriesService;


    @PostMapping("insertForBlogCategories")
    @ApiOperation("增加文章分类")
    public ResultVO insert(@RequestBody BlogCategoriesDTO blogCategoriesDTO){
        log.debug("增加文章分类{}",blogCategoriesDTO);


        blogCategoriesService.insertForBlogCategories(blogCategoriesDTO);
        return ResultVO.ok();
    }

    @PostMapping("/{id}/deleteForBlogCategories")
    @ApiOperation("删除文章分类")
    public ResultVO delete(@PathVariable Long id){
        log.debug("删除文章分类{}",id);

        blogCategoriesService.deleteForBlogCategories(id);
        return ResultVO.ok();
    }

    @PostMapping("/{id}/updateForBlogCategories")
    @ApiOperation("修改文章分类")
    public ResultVO update(@PathVariable Long id){
        log.debug("修改文章分类{}",id);

        blogCategoriesService.updateForBlogCategories(id);
        return ResultVO.ok();
    }

    @PostMapping("")
    @ApiOperation("查询文章分类")
    public ResultVO select(){
        log.debug("查询文章分类");

        blogCategoriesService.selectForBlogCategories();
        return ResultVO.ok();
    }

}
